import React from "react";
import Loadable from "react-loadable";
import Loading from "../loading";

/**
 * 基于 react-loadable 作为动态加载组件
 *
 * 使用方式：
 * const xx = Loader(() => import('./pages/xx'));
 *
 * @param loader 任意组件
 */
const Loader = (loader: any) => {
    return Loadable({
        loader,
        loading() {
            return <Loading/>
        },
    });
};

export default Loader;
